//////////////////////////////////////////////////////////////////////////////////
//	Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef STATTAB_H_
#define STATTAB_H_

#include "def.h"
#include "logctrl.h"

class CStatTab: public wxPanel, public IGUIBind, public ILoggable, public ITabedPageUI
{
public:
								CStatTab(class wxWindow* pParent);
	virtual						~CStatTab();
	
	//IGUIBind
	virtual void				OnResponse(const COMMANDRESPONSE& resp);
	virtual void				Reset();
	
	
	//List
	long						GetItemCount(wxWindowID id);
	wxString					GetItemText(long item, long column, wxWindowID id);
	

	bool						OnDropText(wxCoord x, wxCoord y, const wxString& data) { return false; }
	void						OnDragDropFinished( wxWindowID id, wxDragResult result) {}

	int							GetItemColumnImage(long item, long column, wxWindowID id)
	{
		return -1;
	}

	virtual int					GetItemImage(long item, wxWindowID id)
	{
		return -1;
	}

	class wxListItemAttr*		GetItemAttr(long item, wxWindowID id)
	{
		return NULL;
	}

	virtual wxString			GetLog();

	virtual cTabPageID			GetTabID()					{ return cTabIDBandwidth; }
	virtual bool				IsTimeSelectorSupported()	{ return true;			}
	virtual time_t				GetTimeInterval()			{ return m_tInt;		}
	virtual void				SetTimeInterval(size_t tInt);
	
	
protected:
	void						OnWirelessStat( const RTSTRING& strData );
	void						OnInterfaceStat( const RTSTRING& strData );
	void						OnPing( const RTSTRING& strData );
	
	wxString 					GetRecvItemText(long item, long column);
	wxString 					GetTranItemText(long item, long column);
	wxString 					GetWirelessItemText(long item, long column);

	void						OnInterfaceChanged(wxCommandEvent& ev);
	void						OnRecvColor(wxCommandEvent& ev);
	void						OnSendColor(wxCommandEvent& ev);

	DECLARE_EVENT_TABLE()
	
private:
	class wxListCtrl*			m_plstInfcRecv;
	class wxListCtrl*			m_plstInfcTrancv;
	class wxListCtrl*			m_plstInfcWireless;
	class CTraficGraph*			m_pGraph;
	class wxStaticText*			m_pRecvRate;
	class wxStaticText*			m_pRecvTotal;
	class wxStaticText*			m_pSendRate;
	class wxStaticText*			m_pSentTotal;
	class wxComboBox*			m_pcIntSelector;
	class CTraficColorSelector* m_pRecvArrow;
	class CTraficColorSelector* m_pTransmArrow;

	class CLevelGraph*			m_pLinePing;
	
	PROCTABLEWITHHEADER			m_tableDev;
	PROCTABLEWITHHEADER			m_tableWireless;

	unsigned long				m_lJIT;
	unsigned long				m_lRTT;

	time_t						m_tInt;

	typedef std::vector<wxString> INTLIST;
	INTLIST						m_arrstrInterfaceList;
};

#endif /*STATTAB_H_*/
